﻿using System;
using CxRomos.Web.UserControls.Intefaces;
using CxRomos.Web.UserControls.Presenters;

namespace CxRomos.Web.UserControls {
    public partial class LoginLinks : System.Web.UI.UserControl, ILoginLinks {
        private LoginLinksPresenter _presenter;
        protected void Page_Load(object sender, EventArgs e) {
            _presenter = new LoginLinksPresenter();
            _presenter.Init(this);
        }

        protected void lbHome_Click(object sender, EventArgs e) {
            _presenter.Home();
        }

        protected void lbLogOut_Click(object sender, EventArgs e) {
            _presenter.LogOut();
        }

        protected void lbLogin_Click(object sender, EventArgs e) {
            _presenter.LogIn();
        }

        protected void lbRegister_Click(object sender, EventArgs e) {
            _presenter.Register();
        }

        protected void lbEditAccount_Click(object sender, EventArgs e) {
            _presenter.EditAccount();
        }

        public void ShowAppropriateLoginStatePanel(bool isLoggedIn, string username) {
            if (isLoggedIn) {
                pnlLoggedIn.Visible = true;
                pnlNotLoggedIn.Visible = false;
                lblUsername.Text = "Welcome " + username;
            } else {
                pnlLoggedIn.Visible = false;
                pnlNotLoggedIn.Visible = true;
            }
        }
 
    }
}